﻿using System;
using Lin_shop.Services;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

#nullable disable

namespace Lin_shop.Models.Database
{
    public partial class ShopContext : DbContext
    {
        public ShopContext()
        {
        }

        public ShopContext(DbContextOptions<ShopContext> options)
            : base(options)
        {
        }

        public virtual DbSet<Kind> Kinds { get; set; }
        public virtual DbSet<List1> List1s { get; set; }
        public virtual DbSet<List2> List2s { get; set; }
        public virtual DbSet<Shop> Shops { get; set; }
        public virtual DbSet<User> Users { get; set; }
      

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseSqlServer("Data Source=.;Initial Catalog=Shop;Integrated Security=SSPI");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasAnnotation("Relational:Collation", "Chinese_PRC_CI_AS");

            modelBuilder.Entity<Kind>(entity =>
            {
                entity.HasNoKey();

                entity.ToTable("kind");

                entity.Property(e => e.Kind1)
                    .HasMaxLength(10)
                    .HasColumnName("kind")
                    .IsFixedLength(true);

                entity.Property(e => e.KindId)
                    .HasMaxLength(10)
                    .HasColumnName("kindID")
                    .IsFixedLength(true);
            });

            modelBuilder.Entity<List1>(entity =>
            {
                entity.HasNoKey();

                entity.ToTable("list1");

                entity.Property(e => e.Img)
                    .HasColumnType("image")
                    .HasColumnName("img");

                entity.Property(e => e.Jj)
                    .IsUnicode(false)
                    .HasColumnName("jj");

                entity.Property(e => e.Listnumber)
                    .IsRequired()
                    .HasMaxLength(10)
                    .HasColumnName("listnumber")
                    .IsFixedLength(true);

                entity.Property(e => e.Name)
                    .IsRequired()
                    .HasMaxLength(250)
                    .IsUnicode(false)
                    .HasColumnName("name");

                entity.Property(e => e.Price).HasColumnName("price");
            });

            modelBuilder.Entity<List2>(entity =>
            {
                entity.HasNoKey();

                entity.ToTable("list2");

                entity.Property(e => e.Img)
                    .HasColumnType("image")
                    .HasColumnName("img");

                entity.Property(e => e.ListId)
                    .HasMaxLength(10)
                    .HasColumnName("listID")
                    .IsFixedLength(true);

                entity.Property(e => e.ListZt).HasColumnName("listZT");

                entity.Property(e => e.Listnumber)
                    .HasMaxLength(10)
                    .HasColumnName("listnumber")
                    .IsFixedLength(true);

                entity.Property(e => e.Name)
                    .HasMaxLength(250)
                    .HasColumnName("name");

                entity.Property(e => e.Price).HasColumnName("price");

                entity.Property(e => e.Time)
                    .HasColumnType("datetime")
                    .HasColumnName("time");
            });

            modelBuilder.Entity<Shop>(entity =>
            {
                entity.HasNoKey();

                entity.ToTable("shop");

                entity.Property(e => e.Img)
                    .HasColumnType("image")
                    .HasColumnName("img");

                entity.Property(e => e.Jj).HasColumnName("jj");

                entity.Property(e => e.Name)
                    .IsRequired()
                    .HasMaxLength(250)
                    .IsUnicode(false)
                    .HasColumnName("name");

                entity.Property(e => e.Number)
                    .HasMaxLength(10)
                    .HasColumnName("number")
                    .IsFixedLength(true);

                entity.Property(e => e.Price).HasColumnName("price");

                entity.Property(e => e.ShopId).HasColumnName("shopID");

                entity.Property(e => e.ShopZt).HasColumnName("shopZT");
            });

            modelBuilder.Entity<User>(entity =>
            {
                entity.HasNoKey();

                entity.ToTable("user");

                entity.Property(e => e.Username)
                    .IsRequired()
                    .HasMaxLength(250)
                    .HasColumnName("username");

                entity.Property(e => e.Userpassword).HasColumnName("userpassword");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
